package net.entelijan.cobean.bind;

/**
 * Implementing classes define how to bind a component to an attribute
 * of a POJO.
 * Typically the component is a 'cobean'.
 */
public interface IBinding<C> {

    /**
     * Returns a model change listener that is aware how to handle a class of
     * components.
     * @param model The POJO which property will be bound.
     * @param modelProperty The property name of the property that is being bound.
     * @return a new instance of a model change listener.
     */
    public IModelChangeListener createModelChangeListener(IBeanProperty beanProperty, C comp,
            IRemovableFactory removableFactory);

    /**
     * @return The name of the model property to be bound
     */
    public String getModelProperty();

    /**
     * 
     * @param <T> The Class of the model to be bound.
     * @param model The model that will be bound (somehow)
     * @param comp The component that will be bound.
     * 
     * @return A bound instance of the model. Typically a proxy.
     */
    public <T> T bind(T model, C comp);

}
